﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "GcmpGuiMainFrame.h"
#include "OwnerPtr.h"
#include "StatusBarCtrl.h"
#include <vector>
#include "GmGuiTypeDefs.h"

#pragma warning(push)
#pragma warning(disable:4251)

namespace gcmp
{
    class StatusBarCtrl;

    // 状态栏面板
    class GCMP_GUI_MAIN_FRAME_EXPORT StatusBarPanel
    {
        CANNOT_COPY_OR_ASSIGN(StatusBarPanel);
    public:
        StatusBarPanel(const std::wstring& name, int minWidth = 0, int stretch = 0, StatusBarPanelAlignment alignment = SBPA_AlignLeft);
        ~StatusBarPanel(){}

    public:
        const std::wstring& GetName() const {  return m_name; }

        // 在pBefore控件之前插入控件opCtrl，默认插入到最后面
        bool InsertControl(OwnerPtr<StatusBarCtrl> opCtrl, const StatusBarCtrl* pBefore = nullptr);

        // 获得子控件
        int GetSubControlNum() const { return (int)m_panelCtrls.size(); }
        const StatusBarCtrl* GetSubControl(int index) const;
        const StatusBarCtrl* GetSubControlByName(const std::wstring& ctrlName);

        // 移除控件
        bool RemoveControl(const StatusBarCtrl* pCtrl);
        bool RemoveControlByName(const std::wstring& ctrlName);

        void SetMinWidth(int minWidth) { m_minWidth = minWidth; }
        int  GetMinWidth() const { return m_minWidth; }

        void SetStretch(int stretch) { m_stretch = stretch; }
        int  GetStretch() const { return m_stretch; }

        void SetAlignment(StatusBarPanelAlignment alignment) { m_alignment = alignment; }
        int  GetAlignment() const { return m_alignment; }

    private:
        std::wstring    m_name;
        int             m_minWidth;
        std::vector<gcmp::OwnerPtr<StatusBarCtrl> >  m_panelCtrls;

        int                     m_stretch;      //是否延展长度
        StatusBarPanelAlignment m_alignment;    //对齐方式
    };

} // namespace gcmp

#pragma warning(pop)

